//
//  NSMutableAttributedString+RBAdd.m
//  RBDemoProj
//
//  Created by Lan on 2019/1/17.
//  Copyright © 2019年 SummerTea. All rights reserved.
//

#import "NSMutableAttributedString+RBAdd.h"

@implementation NSMutableAttributedString(RBAdd)

- (void)appendFont: (UIFont *)font
             color: (UIColor *)color
       lineSpacing: (CGFloat)lineSpacing
              text: (NSString *)text
   highlighBgColor: (UIColor *)highlighBgColor
    highlightColor: (UIColor *)highlightColor
         tapAction:(YYTextAction)tapAction
   longPressAction:(YYTextAction)longPressAction
{
    NSMutableAttributedString *stringM = [[NSMutableAttributedString alloc] initWithString:text];
    stringM.yy_font = font;
    stringM.yy_color = color;
    stringM.yy_lineSpacing = lineSpacing;
    if (tapAction || longPressAction)
    {
        [stringM yy_setTextHighlightRange:NSMakeRange(0, stringM.length) color:highlightColor backgroundColor:highlighBgColor userInfo:nil tapAction:tapAction longPressAction:longPressAction];
    }
    [self appendAttributedString:stringM];
}

- (void)appendContent: (id)content
          lineSpacing: (CGFloat)lineSpacing
          contentMode:(UIViewContentMode)contentMode
       attachmentSize:(CGSize)attachmentSize
          alignToFont:(UIFont *)font
            alignment:(YYTextVerticalAlignment)alignment
      highlighBgColor: (UIColor *)highlighBgColor
            tapAction:(YYTextAction)tapAction
      longPressAction:(YYTextAction)longPressAction
{
    NSMutableAttributedString *stringM = [NSMutableAttributedString yy_attachmentStringWithContent:content contentMode:contentMode attachmentSize:attachmentSize alignToFont:font alignment:alignment];
    stringM.yy_lineSpacing = lineSpacing;
    if (tapAction || longPressAction)
    {
        [stringM yy_setTextHighlightRange:NSMakeRange(0, stringM.length) color:nil backgroundColor:highlighBgColor userInfo:nil tapAction:tapAction longPressAction:longPressAction];
    }
    [self appendAttributedString:stringM];
}

@end
